<?php
/*
  功能：抽奖奖品分类表 model
  作者：cxm
  时间：2019-10-23
*/

namespace App\Models;

use DateTimeInterface;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use DB;

class AwardGoodsClass extends BaseModel {
    use SoftDeletes;
    protected $dates = ['deleted_at']; //开启deleted_at
    protected $table='award_goods_class';  //绑定表

    /**
     * 奖品
     */
    public function award_goods(){
        return $this->hasOne(AwardGoods::class,'id','award_goods_id');
    }

    /**
     * 文件
     */
    public function file(){
        return $this->hasOne(File::class,'id','img');
    }

    /**
     * 获取指定字段的值
     * @param array $where
     * @param string $field
     * @return mixed
     */
    public static function getField($where=array(),$field=''){
        return self::where($where)->value($field);
    }
}